import pandas as pd
import plotly.express as px
import plotly.io as pio
pio.renderers.default = 'notebook'
data = pd.read_csv("../data/clean_500.csv")
fig = px.scatter_geo(data,
lat='Latitude',
lon='Longitude',
size='Data_Value',
hover_name='CityName',
hover_data={
'StateAbbr': True,
'Data_Value': ':.2f',
'PopulationCount': True,
'Measure': True
},
color='Data_Value',
color_continuous_scale=px.colors.sequential.Teal,
projection='albers usa',
title='Health Insurance Coverage Map')
#change text pos, color, and size of the bubbles
fig.update_traces(
textposition='top center',
marker=dict(
line=dict(width=0)
)
);
fig.update_geos(
landcolor='lightgray',
bgcolor='white',
projection_scale=0.95,
center=dict(lat=37.0902, lon=-95.7129),
showcountries=True,
countrycolor='black',
showsubunits=True,
subunitcolor='black'
);
#color scale changes
fig.update_layout(
coloraxis_colorbar=dict(
title='Data Value (%)',
thicknessmode='pixels', thickness=15,
lenmode='pixels', len=200
),
margin=dict(t=50, l=0, r=0, b=0),
title=dict(
y=0.95,
x=0.5,
xanchor='center',
yanchor='top'
)
);
#hover info
fig.update_layout(
hoverlabel=dict(
bgcolor="white",
font_size=16,
font_family="Rockwell"
)
);
fig.show()